package com.test;

import com.connection.DataConnection;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NewAccount extends Activity {

	private Button submit, clear, back;
	private EditText e_name, e_password, e_phone, e_address;

	DataConnection data = new DataConnection(this);

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);

		e_name = (EditText) findViewById(R.id.editText1);
		e_password = (EditText) findViewById(R.id.editText2);
		e_phone = (EditText) findViewById(R.id.editText3);
		e_address = (EditText) findViewById(R.id.editText4);

		submit = (Button) findViewById(R.id.submit);
		submit.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				String name = e_name.getText().toString();
				String password = e_password.getText().toString();
				String phone = e_phone.getText().toString();
				String address = e_address.getText().toString();
				data.open();				
				data.addUserInfo(name, password, phone, address);
				data.close();

				startActivity(new Intent(NewAccount.this, ProductActivity.class));
			}

		});
		
		clear = (Button) findViewById(R.id.clear);
		clear.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				Toast.makeText(getApplication(), "String", Toast.LENGTH_LONG);
				e_name.setText("");
				e_password.setText("");
				e_phone.setText("");
				e_address.setText("");

			}

		});
		back = (Button) findViewById(R.id.back);
		back.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				startActivity(new Intent(NewAccount.this, MainActivity.class));

			}

		});
	}

}
